﻿using System;
using System.Data;

namespace GeoWeb.Controls.WebGrid
{
    /// <summary>
    /// WebGrid中编辑单元格后当设置单元格失去焦点自动保存时
    /// 在服务端的WebGridAfterCellEdit事件中可接收到该类型的参数
    /// </summary>
    public class WebGridAfterCellEditEventArgs : EventArgs
    {
        private string field;
        /// <summary>
        /// 当前编辑的单元格所属列对应的字段名称
        /// </summary>
        public string Field
        {
            get { return field; }
        }

        private string oldValue;
        /// <summary>
        /// 当前编辑的单元格编辑之前的值，用于与编辑之后的值进行对比
        /// </summary>
        public string OldValue
        {
            get { return oldValue; }
        }

        private string newValue;
        /// <summary>
        /// 当前编辑的单元格编辑之后的值
        /// </summary>
        public string NewValue
        {
            get { return newValue; }
        }

        private DataRow editRow;
        /// <summary>
        /// 当前编辑的单元格所在行的数据行
        /// </summary>
        public DataRow EditRow
        {
            get { return editRow; }
        }

        private bool isSuccess;
        /// <summary>
        /// Boolean值，用于确定当前编辑的单元格是否保存成功
        /// </summary>
        public bool IsSuccess
        {
            get { return isSuccess; }
            set { isSuccess = value; }
        }

        internal WebGridAfterCellEditEventArgs(
            string _field,
            string _oldValue,
            string _newValue,
            DataRow _editRow
        )
        {
            this.field = _field;
            this.oldValue = _oldValue;
            this.newValue = _newValue;
            this.editRow = _editRow;
        }
    }

    public delegate void WebGridAfterCellEditEventHandler(object sender, WebGridAfterCellEditEventArgs e);
}